package com.mediacloud.app.newsmodule.fragment.baoliao.model;

import org.json.JSONObject;

public class BaoLiaoLayerField
{
    public boolean contentIsMust,locationMust,phoneMust,realNameMust;
    /**
     * 爆料里面是否显示栏目
     * */
    boolean lanMuMust;

    String select_catalog_id;

    private Statement statement;

    public Statement getStatement() {
        return statement;
    }

    public static BaoLiaoLayerField parseMeta(JSONObject meta)
    {
        BaoLiaoLayerField baoLiaoLayerField=new BaoLiaoLayerField();
        baoLiaoLayerField.contentIsMust=meta.optJSONObject("content").optInt("required",0)==1;
        baoLiaoLayerField.locationMust=meta.optJSONObject("location").optInt("required",0)==1;
        baoLiaoLayerField.phoneMust=meta.optJSONObject("phone").optInt("required",0)==1;
        baoLiaoLayerField.realNameMust=meta.optJSONObject("realname").optInt("required",0)==1;
        baoLiaoLayerField.lanMuMust = meta.optJSONObject("catalogid").optInt("required",0)==1;
        baoLiaoLayerField.select_catalog_id = meta.optString("select_catalog_id","");
        baoLiaoLayerField.statement = new Statement();
        JSONObject jsonObject = meta.optJSONObject("statement");
        if(jsonObject != null){
            baoLiaoLayerField.statement.content = jsonObject.optString("content");
            baoLiaoLayerField.statement.title = jsonObject.optString("title");
            baoLiaoLayerField.statement.require = jsonObject.optInt("switch",0)==1;
        }
        return baoLiaoLayerField;
    }

    public boolean isLanMuMust() {
        return lanMuMust;
    }

    public String getSelect_catalog_id() {
        return select_catalog_id;
    }

    public static class Statement{
        private String content;
        private String title;
        /**
         * 是否需要，后台给的字段是 switch
         * */
        private boolean require = false;

        public String getContent() {
            return content;
        }

        public String getTitle() {
            return title;
        }

        public boolean isRequire() {
            return require;
        }
    }
}